# # python的打印到控制台
# print('hello')
# print(1 + 2 - 3)
# print(1 + 2 * 3)
# print(1 + 2 / 3)

# # 求四个数的方差
# avg = ((67.5 + 89.0 + 12.9 + 32.2) / 4)
# total = (67.5 - avg) ** 2 + (89.0 - avg) ** 2 + (12.9 - avg) ** 2 + (32.0 - avg) ** 2
# result = total / 3
# print(result)

# # 初始化+赋值+修改
# a = 10
# b = a
# print(b)
# a = 20
# print(a)

# # 变量的类型
# a1 =10   #整型
# print(type(a1))  #type查看变量类型
#
# b1 = 0.5 #浮点数
# print(type(b1))
#
# c = 'hello' #字符串
# print(type(c))
#
# d = "hello" #字符串
# print(type(d))
#
# e = 'my name is "zhanfeng"' #字符串中有双引号，用单引号赋值
# print(type(e))
#
# f = '''My 'name' is "zhanfeng"''' #如果单双引号都有，用三引号赋值
# print(f)
#
# print(len(d)) #len函数是求字符串长度，相当于C中的strlen
#
# a2 = "hello"
# b2 = " world"
# print(a2 + b2) #字符串拼接，不影响a2 b2

# # bool类型
# c1 = True
# c2 = False
# print(type(c1))
# print(type(c2))

# # 动态类型
# aa = 10
# print(type(a))
# aa = "hello"
# print(type(aa))
# aa = True
# print(type(aa))

# # 类型声明 - 可以不加
# aa:int = 10
# aa:str = 'hello'

# # 如何使用 print 打印出 “a = 10” 这样的内容
# a = 10
# print(f"a = {a}")
# print(f"a = {a + 10}")

# 通过控制台来输入
# num = input('请输入一个整数：')
# print(type(num))
# print(f'您输入的数字是 {num}')
#
# a = input('请输入第一个整数: ')
# b = input('请输入第二个整数: ')
#
# a = int(a)
# b = int(b)
# print(f'a + b = {a + b}')

# # 输入4个小数，求四个小数的平均值
# a = input('请输入第一个数字：')
# b = input('请输入第二个数字：')
# c = input('请输入第三个数字：')
# d = input('请输入第四个数字：')
#
# a = float(a)
# b = float(b)
# c = float(c)
# d = float(d)
#
# avg = (a + b + c + d) / 4
# print(f'平均值是：{avg}')

####################################################################
# # 运算符
# result = 1 + 2 * 3
# print(result)
#
# result = (1 + 2) * 3
# print(result)
#
# # print(10 / 0.0)  # 0不能做除数
#
# a = 1 / 2
# print(a)  # python不会发生截断，得到的是小数
# a = int(a)  # 转成int型，即可实现和c++一样的除法
# print(a)
#
# # %求余
# print(7 % 5)
#
# # **乘方运算，支持开方运算，指数可以是小数
# print(4 ** 2)
# print(4 ** 3)
# print(4 ** 0.5)
#
# # //地板除法(取整除法)，会针对计算的结果进行 “向下取整”
# print(7 // 2)
# print(-7 // 2)

# # 关系运算符
# a = 10
# b = 20
# print(a < b)
# print(a > b)
# print(a <= b)
# print(a >= b)
# print(a != b)
# print(a == b)
#
# c = 'hello'
# d = 'world'
# print(d == c)
# print( d != c)

# # 浮点数的关系运算符
# # 浮点数不可直接使用 ==  !=
# print(0.1 + 0.2 == 0.3)
# print(0.1)
# print(0.2)
# print(0.1 + 0.2)
# print(0.3)
#
# # 正确比较的浮点数的方法 -- 做差(看误差)
# a = 0.1 + 0.2
# b = 0.3
# # 看 a - b 的差是否在误差范围内
# print(- 0.000001 < (a - b) < 0.000001)  # python中支持连续赋值

# # 逻辑运算符 and(与) or(或) not(非)
# a = 10
# b = 20
# c = 30
#
# print(a < b < c)  # 推荐使用链式比较的方法
# print(a < b and b > c)
#
# print(a > b or b < c)
# print(a < b or b > c)
# print(a > b or b > c)
#
# print(not a < b)
# print(not a > b)
#
# # 短路求职
# print(a > b and 10 / 0 == 1)
# print(a < b or 10 / 0 == 0)

# # 赋值运算符(把右侧的值填入左侧的空间)
# a = b = 20  # 可链式赋值，不建议
# a, b = 10, 20 # 多元赋值 -> 可以帮助我们交换两个数值
#
# # 一般用第三个变量两个数交换
# print(a,b)
# tmp = a
# a = b
# b = tmp
# print(a,b)
#
# # 使用多元赋值交换，一步到位
# print(a,b)
# a, b = b, a
# print(a,b)

# # 复合赋值运算
# # 除此之外还有 -= *=  /= **= //= %= 但一定要保证 a 初始化
# # python中不支持 ++ --操作
# a = 0
# a = a + 1
# print(a)
# a += 1
# print(a)

# # 复合赋值运算
# # 除此之外还有-=*=/= **=//= %= 但一定要保证 a 初始化
# # python中不支持 ++--操作
# a = 0
# a = a + 1
# print(a)
# a += 1
# print(a)